package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/1/4 10:47
 * @apiNote
 */

public class Test00812LargestTriangleArea {

    public double largestTriangleArea(int[][] points) {
        int n = points.length;
        double res = 0.0;
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                for(int k = j + 1; k < n; k++){
                    res = Math.max(res, triangleArea(points[i], points[j], points[k]));
                }
            }
        }
        return res;
    }

    public static double triangleArea(int[] p1, int[] p2, int[] p3) {
        return 0.5 * Math.abs(p1[0] * p2[1] + p2[0] * p3[1] + p3[0] * p1[1] - p1[0] * p3[1] - p2[0] * p1[1] - p3[0] * p2[1]);
    }
}
